<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HMS管理系统登陆</title>
<link rel="stylesheet" type="text/css" href="css/index.css" /> 
</head>

<body>
<body>
	<div class="login">
		<div class="login-screen">
			<div class="app-title">
				<h1>人事管理系统登陆</h1>
			</div>

			<div class="login-form">
				<div class="control-group">
					<input type="text" class="login-field" value=""
						placeholder="username" id="login-name"> <label
						class="login-field-icon fui-user" for="login-name"></label>
				</div>

				<div class="control-group">
					<input type="password" class="login-field" value=""
						placeholder="password" id="login-pass"> <label
						class="login-field-icon fui-lock" for="login-pass"></label>
				</div>

				<a class="btn btn-primary btn-large btn-block" href="#"
					onclick="login(this)">登陆</a> 
				<div id="regist">
					<a href="#" id="forget">忘记密码？</a>
					<a href="#" id="regist">注册</a>
				</div>
				
			</div>
		</div>
	</div>
	<script type="text/javascript" src="jquery.js"></script>
	<script>
		$(function(){
			$("#regist").click(function(){
				location.href = "registration.html";
			});
		});
		
		function login(){
			//获取用户名和密码
			var userName = $("#login-name").val();
			var pwd = $("#login-pass").val();
			//非空验证
			if(!userName || !pwd){
				alert("用户名或者密码不能为空。");
			}
			//用户验证
			$.ajax({
				type : "get",
				url : "/HMS/login",
				dataType : 'json',
				data:{"userName":userName,"pwd":pwd},
				contentType : "application/json;charset=UTF-8",
				success : function(value) {
					if(value.msg == "OK"){
						//登陆成功
						location.href = "/HMS/main";
					}else{
						//登陆失败
						alert("用户名或者密码错误。")
					}
				},
				error : function(data) {
					alert('失败!');
				}
			});
		}
	</script>
</body>
</html>